home *** CD-ROM | disk | FTP | other *** search
/ Amiga Plus 2002 #11 / Amiga Plus CD - 2002 - No. 11.iso / Tools / AmigaSystem / Scalos / GuiGFXLib / src / guigfx_pensharemap.c < prev    next >
Encoding:
C/C++ Source or Header  |  2002-10-28  |  2.2 KB  |  101 lines

  1. /*********************************************************************
  2. ----------------------------------------------------------------------
  3.  
  4.     guigfx_pensharemap
  5.     
  6. ----------------------------------------------------------------------
  7. *********************************************************************/
  8.  
  9. #include <render/render.h>
  10. #include <utility/tagitem.h>
  11.  
  12. #include <exec/lists.h>
  13.  
  14. #include <proto/render.h>
  15. #include <proto/exec.h>
  16. #include <proto/utility.h>
  17.  
  18. #include <guigfx/guigfx.h>
  19.  
  20. #include "guigfx_global.h"
  21.  
  22.  
  23. /*********************************************************************
  24. ----------------------------------------------------------------------
  25.  
  26.     psm = CreatePenShareMap ( tags )
  27.  
  28.     create and set-up a pensharemap.
  29.     
  30.     GGFX_HSType                Auflösung des Histogramms    default: 12BIT_TURBO
  31.  
  32. ----------------------------------------------------------------------
  33. *********************************************************************/
  34.  
  35. PSM SAVE_DS ASM *CreatePenShareMapA(REG(a0) TAGLIST taglist)
  36. {
  37.     PSM *psm;
  38.     
  39.     if (psm = (PSM *) AllocRenderVec(MemHandler, sizeof(struct PenShareMap)))
  40.     {
  41.         ULONG default_hstype = DEFAULT_HSTYPE;
  42.  
  43.         psm->histogram = NULL;
  44.  
  45.         psm->hstype =
  46.             GetTagData(GGFX_HSType, default_hstype, taglist);
  47.  
  48.         DB(kprintf("(!) Histogramm der Pensharemap: %ld\n", psm->hstype));
  49.  
  50.         InitSemaphore(&psm->semaphore);
  51.         NewList(&psm->colorlist);
  52.         psm->numcolorhandles = 0;
  53.         psm->modified = FALSE;
  54.  
  55.         return psm;
  56.     }
  57.  
  58.     return NULL;
  59. }
  60.  
  61.  
  62. /*********************************************************************
  63. ----------------------------------------------------------------------
  64.  
  65.     DeletePenShareMap(psm)
  66.  
  67. ----------------------------------------------------------------------
  68. *********************************************************************/
  69.  
  70. void SAVE_DS ASM DeletePenShareMap(REG(a0) PSM *psm)
  71. {
  72.     if (psm)
  73.     {
  74.         struct Node *node; 
  75.  
  76.         ObtainSemaphore(&psm->semaphore);
  77.     
  78.         if (psm->histogram)
  79.         {
  80.             DeleteHistogram(psm->histogram);
  81.         }
  82.     
  83.         if (!IsListEmpty(&psm->colorlist))
  84.         {
  85.             struct Node *nextnode;
  86.             node = (struct Node *) psm->colorlist.lh_Head;
  87.             while (nextnode = node->ln_Succ)
  88.             {
  89.                 RemColorHandle((COLORHANDLE *)node);
  90.                 node = nextnode;
  91.             }
  92.         }
  93.     
  94.         ReleaseSemaphore(&psm->semaphore);
  95.     
  96.         FreeRenderVec(psm);
  97.     }
  98.     
  99. }
  100.  
  101.